home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / mkmf / RCS / mkmf.boot,v < prev    next >
Encoding:
Text File  |  1991-04-11  |  8.1 KB  |  409 lines

  1. head     1.9;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.9
  10. date     91.04.11.12.52.45;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.8;
  13.  
  14. 1.8
  15. date     89.10.09.21.27.14;  author rab;  state Exp;
  16. branches ;
  17. next     1.7;
  18.  
  19. 1.7
  20. date     89.08.18.11.21.20;  author douglis;  state Exp;
  21. branches ;
  22. next     1.6;
  23.  
  24. 1.6
  25. date     89.08.17.11.14.39;  author douglis;  state Exp;
  26. branches ;
  27. next     1.5;
  28.  
  29. 1.5
  30. date     89.08.17.11.05.09;  author douglis;  state Exp;
  31. branches ;
  32. next     1.4;
  33.  
  34. 1.4
  35. date     89.04.06.21.40.06;  author jhh;  state Exp;
  36. branches ;
  37. next     1.3;
  38.  
  39. 1.3
  40. date     88.07.21.10.41.55;  author douglis;  state Exp;
  41. branches ;
  42. next     1.2;
  43.  
  44. 1.2
  45. date     88.07.11.12.15.19;  author deboor;  state Exp;
  46. branches ;
  47. next     1.1;
  48.  
  49. 1.1
  50. date     88.03.18.15.06.04;  author deboor;  state Exp;
  51. branches ;
  52. next     ;
  53.  
  54.  
  55. desc
  56. @Subscript for boot programs
  57. @
  58.  
  59.  
  60. 1.9
  61. log
  62. @Flush DEFTARGET: the default target is now determined by a pmake
  63. library file.
  64. @
  65. text
  66. @#!/sprite/cmds/csh -f
  67. #
  68. # A script to generate (or regenerate) a source (cmds) directory  Makefile
  69. # from a prototype Makefile.  If ./Makefile.proto exists, use it, else
  70. # use a common prototype.
  71. #
  72. # We assume we were invoked from mkmf, thus we don't need to alter the
  73. # path, and MKMFDIR is in the environment to tell us where to find prototype
  74. # makefiles, etc.
  75. #
  76. # Parameters passed in from mkmf as environment variables:
  77. #
  78. #    DOMACHINES    names of machines we are supposed to run mkmf on
  79. #    MKMFDIR        directory containing prototype makefiles
  80. #    MKMFFLAGS    arguments to all mkmfs run recursively
  81. #    MACHINES    list of machine names (e.g. "sun2 sun3"), for
  82. #            which there are machine-dependent subdirectories
  83. #            (sun2.md, sun3.md) to hold the object files and
  84. #            any machine-specific source files to use when
  85. #            compiling for that machine
  86. #    MAKEFILE    name of makefile to create
  87. #    SUBTYPE        information about what type of command this is:
  88. #            used to figure out where to install things.
  89. #
  90. # Several of these environment variables must be copied to local shell
  91. # variables before use, because shell variables can be used in some places
  92. # where environment variables can't.
  93.  
  94. #
  95. # Argument processing.  (Generalized form, even though just one flag so far.)
  96. #
  97. while ($#argv >= 1)
  98.     if ("$1" == '-x') then
  99.     set echo
  100.     endif
  101.     shift
  102. end
  103.  
  104. set nonomatch
  105. set srcs =(*.[hcsly] *.md/*.[hcslyo])
  106. set mds = (*.md)
  107. set manPages = (*.man)
  108. if ("$mds" == "*.md") then
  109.     set mds = ()
  110. endif
  111. if ("$manPages" == "*.man") then
  112.     set manPages = ()
  113. endif
  114. #
  115. # Check to see if there were any sources.  The first check (size == 2, the
  116. # number of strings that would be there if there were no matches)
  117. # is only necessary because the second check will cause an error if
  118. # srcs contains more than 1024 bytes.  If no sources, then assume that
  119. # this directory contains only a shell script (and eliminate any
  120. # machine-dependent subdirectories that Pmake might have created).
  121. #
  122. if ($#srcs == 2) then
  123.     if ("$srcs" == "*.[hcsly] *.md/*.[hcslyo]") unset srcs
  124. endif
  125. unset nonomatch
  126. if (! $?srcs) then
  127.     echo "No sources, assuming shell script."
  128.     if ("$mds" != "") then
  129.     echo "Deleting extraneous subdirectories $mds."
  130.     rm -rf $mds
  131.     endif
  132.     $MKMFDIR/mkmf.script $*
  133.     exit $status
  134. endif
  135.  
  136. set subtype=$SUBTYPE
  137. set prog=$cwd:t
  138. set machines=($MACHINES)
  139. set domachines = ($DOMACHINES)
  140. set makefile=($MAKEFILE)
  141. set distdir=($DISTDIR)
  142.  
  143. if (-e $makefile.proto) then
  144.     set proto=$makefile.proto
  145. else
  146.     set proto="${MKMFDIR}/Makefile.boot"
  147. endif
  148.  
  149. echo "Generating $makefile for $prog using $proto"
  150.  
  151.  
  152. cat $proto | sed \
  153.     -e "s,@@(DATE),`date`,g" \
  154.     -e "s,@@(MACHINES),$machines,g" \
  155.     -e "s,@@(MAKEFILE),$makefile,g" \
  156.     -e "s,@@(MANPAGES),$manPages,g" \
  157.     -e "s,@@(NAME),$prog,g" \
  158.     -e "s,@@(TEMPLATE),$proto,g" \
  159.     -e "s,@@(TYPE),$subtype,g" \
  160.     -e "s,@@(DISTDIR),$distdir,g" \
  161.     > $makefile
  162.  
  163. setenv PARENTDIR $cwd
  164. foreach i ($domachines)
  165.     (cd $i.md; mkmf $MKMFFLAGS -f md.mk)
  166. end
  167. @
  168.  
  169.  
  170. 1.8
  171. log
  172. @Modifications for distribution.
  173. @
  174. text
  175. @a12 1
  176. #    DEFTARGET    name of default target
  177. a75 1
  178. set defTarget=($DEFTARGET)
  179. a88 1
  180.     -e "s,@@(DEFTARGET),${defTarget:q},g" \
  181. @
  182.  
  183.  
  184. 1.7
  185. log
  186. @another change for TM -- use single machine if it exists, else \ds3100
  187. @
  188. text
  189. @d78 1
  190. d98 1
  191. @
  192.  
  193.  
  194. 1.6
  195. log
  196. @removed DEFTARGET -- we use $MACHINE now
  197. @
  198. text
  199. @d13 1
  200. d77 1
  201. d90 1
  202. @
  203.  
  204.  
  205. 1.5
  206. log
  207. @this was owned by brent and writable but not checked out.  dunno.
  208. @
  209. text
  210. @a12 1
  211. #    DEFTARGET    name of default target
  212. a75 1
  213. set defTarget=($DEFTARGET)
  214. a87 1
  215.     -e "s,@@(DEFTARGET),$defTarget,g" \
  216. @
  217.  
  218.  
  219. 1.4
  220. log
  221. @added abilty to make specific machine types
  222. @
  223. text
  224. @d3 2
  225. a4 2
  226. # A script to generate (or regenerate) a boot program Makefile
  227. # from the prototype Makefile.  If ./Makefile.proto exists, use it, else
  228. d11 2
  229. a12 1
  230. # Variables:
  231. d14 1
  232. a14 5
  233. #    type        type of makefile to make (e.g. att, src, local, etc.)
  234. #    prog        program to create (directories are assumed to be named
  235. #            after the programs they create)
  236. #    pref        prefix pattern that files must match to be included
  237. #    makefile    name of the makefile to create
  238. d16 41
  239. d58 2
  240. a59 7
  241. set prog=$cwd:t
  242. set module=$prog
  243. set pref='[a-z_A-Z]'
  244.  
  245. if ($?MACHINES == 0) then
  246.     echo "No target machines for $module, using local type $MACHINE"
  247.     setenv MACHINES = $MACHINE
  248. d61 9
  249. a69 4
  250. set machines=($MACHINES)
  251. if ("$machines" == "") then
  252.     echo "No target machines for $module, using local type $MACHINE"
  253.     set machines = $MACHINE
  254. d72 6
  255. a77 5
  256. if ($?MAKEFILE) then
  257.     set makefile=$MAKEFILE
  258. else
  259.     set makefile=Makefile
  260. endif
  261. a83 5
  262. set installdir=/sprite/boot
  263.  
  264. echo "Generating a Makefile for $prog using $proto"
  265.  
  266. set defTarget=($DEFTARGET)
  267. d85 1
  268. a85 15
  269. #
  270. # First figure out what's there by way of .c, .y, .l, .s, .p, .h and .o files
  271. # If any one doesn't have any members, it'll contain the original
  272. # pattern (b/c of nonomatch). We want it to be empty, though, so
  273. # we reset it.
  274. #
  275. set nonomatch
  276. set srcs=( ${pref}*.[cylsp] )
  277. if ("$srcs" == "${pref}*.[cylsp]") set srcs=()
  278. set Hfiles=( ${pref}*.h )
  279. if ("$Hfiles" == "${pref}*.h") set Hfiles=()
  280. rm -f version.o
  281. set Ofiles=( ${pref}*.o )
  282. if ("$Ofiles" == "${pref}*.o") set Ofiles=()
  283. unset nonomatch
  284. a86 13
  285. #
  286. # Merge in any .o files that can be created from local source files but don't
  287. # exist yet. In addition, figure out which .o files may be safely removed
  288. # during a "make clean" and store them in RmOfiles.
  289. #
  290. set RmOfiles=""
  291. if ("$srcs" != "") then
  292.     foreach file ($srcs)
  293.         set file=$file:r.o
  294.         set RmOfiles=($RmOfiles $file)
  295.         if (! -e $file) set Ofiles=($Ofiles $file)
  296.     end
  297. endif
  298. d89 3
  299. a91 5
  300.     -e "s,@@(PROGRAM),$prog,g" \
  301.     -e "s,@@(OBJS),$Ofiles,g" \
  302.     -e "s,@@(CLEANOBJS),$RmOfiles,g" \
  303.     -e "s,@@(SRCS),$srcs,g" \
  304.     -e "s,@@(HDRS),$Hfiles,g" \
  305. d93 2
  306. a94 2
  307.     -e "s,@@(MACHINES),$machines,g" \
  308.     -e "s,@@(DEFTARGET),$defTarget,g" \
  309. d96 2
  310. a97 3
  311.     -e "s,@@(DATE),`date`,g" \
  312.     -e "s,@@(INSTALLDIR),$installdir,g" > $makefile
  313. endif
  314. d99 4
  315. @
  316.  
  317.  
  318. 1.3
  319. log
  320. @Brent actually had this checked out.  I'm not sure, but I think Brent
  321. changed this for machine-dependent directories.
  322. @
  323. text
  324. @d12 1
  325. d49 1
  326. a49 5
  327. if (" $machines " =~ *\ sun3\ *) then
  328.     set defTarget=sun3
  329. else
  330.     set defTarget=$machines[1]
  331. endif
  332. @
  333.  
  334.  
  335. 1.2
  336. log
  337. @adam's original version
  338. @
  339. text
  340. @d20 1
  341. d23 10
  342. d48 6
  343. d91 2
  344. d97 1
  345. @
  346.  
  347.  
  348. 1.1
  349. log
  350. @Initial revision
  351. @
  352. text
  353. @d4 2
  354. a5 1
  355. # from the prototype Makefile.
  356. d7 14
  357. a20 2
  358. set path = (/sprite/cmds /sprite/local/cmds /sprite/att/cmds)
  359. rehash
  360. d22 5
  361. a26 2
  362. set module=`pwd`
  363. set module=$module:t
  364. d28 2
  365. a29 14
  366. echo "Generating a Makefile for boot programs"
  367.  
  368. unalias ls
  369. set nonomatch
  370. set Cfiles=`ls [a-z_]*.c`
  371. set Hfiles=`ls [a-z_]*.h`
  372. set Sfiles=`ls [a-z_]*.s`
  373.  
  374. set Ofiles=`echo $Cfiles $Sfiles | sed -e "s/\.c/.o/g" -e "s/\.s/.o/g"`
  375.  
  376. if (-e Makefile) mv  Makefile Makefile.$$~
  377.  
  378. if (-e Makefile.proto) then
  379.     set proto=Makefile.proto
  380. d31 1
  381. a31 1
  382.     set proto=/sprite/src/lib/makemake/Makefile.boot
  383. d33 1
  384. d35 1
  385. a35 7
  386. cat $proto | \
  387.     sed -e "s/module-name/$module/" \
  388.     -e "s/^CSRCS.*/CSRCS = $Cfiles/" \
  389.     -e "s/^ASMSRCS.*/ASMSRCS = $Sfiles/" \
  390.     -e "s/^HDRS.*/HDRS = $Hfiles/" \
  391.     -e "s/^OBJS.*/OBJS = $Ofiles/" \
  392.     > Makefile
  393. d37 28
  394. a64 5
  395. if (-e Makefile.sed) then
  396.     echo "Modifying with Makefile.sed."
  397.     mv Makefile{,.$$~~}
  398.     sed -f Makefile.sed Makefile.$$~~ > Makefile
  399.     rm Makefile.$$~~
  400. d67 10
  401. a76 3
  402. if (-e Makefile.ex) then
  403.     echo "Modifying with Makefile.ex."
  404.     ex - Makefile < Makefile.ex
  405. a77 2
  406.  
  407. make depend
  408. @
  409.